package org.ant.handler.typeChecking;

import java.util.ArrayList;

public class MethodDesc{
	
	
	
	String methodName;
	String returnType;
	String alias;
	ClassDesc inClass;
	ArrayList<VarDesc> vars;
	ArrayList<MethodParameter> parameters;
	
	public MethodDesc(String methodName, String returnType,
			ArrayList<MethodParameter> parameters) {
		super();
		this.methodName = methodName;
		this.returnType = returnType;
		this.parameters = parameters;
		this.vars = new ArrayList<VarDesc>();
	}
	
	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}

	public String getReturnType() {
		return returnType;
	}

	public void setReturnType(String returnType) {
		this.returnType = returnType;
	}

	public ClassDesc getInClass() {
		return inClass;
	}

	public void setInClass(ClassDesc inClass) {
		this.alias = this.methodName+":";
		for (int i = 0;i<parameters.size();i++){
			MethodParameter p = parameters.get(i);
			alias += p.type;
			if (i<parameters.size()-1){
				alias += ",";
			}
		}
		alias += "@"+inClass.className;
		this.inClass = inClass;
	}

	public ArrayList<MethodParameter> getParameters() {
		return parameters;
	}

	public void setParameters(ArrayList<MethodParameter> parameters) {
		this.parameters = parameters;
	}
	
	
	
	
	public ArrayList<VarDesc> getVars() {
		return vars;
	}

	public void setVars(ArrayList<VarDesc> vars) {
		this.vars = vars;
	}

	public void addVariable(VarDesc var){
		this.vars.add(var);
	}

	public String getAlias() {
		return alias;
	}

	public void setAlias(String alias) {
		this.alias = alias;
	}

	public VarDesc getVarByName(String id) {
		for (VarDesc v:this.vars){
			if (v.getName().equals(id)){
				return v;
			}
		}
		return null;
	}
	
}
